{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "# Ch `04`: Concept `01`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Linear regression for classification (just for demonstrative purposes)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Import the usual libraries:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Let's say we have numbers that we want to classify. They'll just be 1-dimensional values. Numbers close to 5 will be given the label `[0]`, and numbers close to 2 will be given the label `[1]`, as designed here:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x7f5be2699fd0>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAEACAYAAACwB81wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAElFJREFUeJzt3H+M5Hd93/Hn63w+e417hgMDiY3vaAyBEhzOrmyrpHSQ\nSX2kyI4UiZyTUIJSJ1JruUqVym7UyGs1f8Sp1ISIJMSt45iEy6YQQZw0hoPCJCKp4yv+gXO+yxnQ\nOjYkvsWlRQ4kcsy7f+z4WNazuzM3s/ODz/Mhjfz98Z7P5z0z59d857M7m6pCkvStb8e0G5AkTYaB\nL0mNMPAlqREGviQ1wsCXpEYY+JLUiLEEfpI7k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U\nMJf/2GH1OxRV9WBv+2ngGHDBdLsaTlV9tbd5Fqu/jDD9K5kBJbkQ+D7gv027l9MUZidLhtL71v8/\nrao7Aarq7+cx7HveAnxuo7CH2XmRLgDWNvkEcxY43yqS7APeAPzZdDsZTm9J5AHgr4GPVdWRafc0\nhF8A/j1z9Ca1TgEfTXIkyfXTbmZIrwS+lOTO3rLI7UkWpt3UafpB4Lc3K5iVwNcM6C3nfBD4t70r\n/blRVV+vqv3AhcAVSf7RtHsaRJJ/ATzZ+4SV3m3evLGq/jGrn1L+TW+Jc17sBC4FfrmqLgW+yurf\nCJsrvV9/vwb4wGZ1sxL4XwAuWrN/Ye+YJqS3dvlB4Der6nnfp5gXvY/jnwQOTLuXAb0RuKa3Dv7b\nwJuTvG/KPQ2l9zeyqKoV4EOsLtHOiyeAx6vqf/f2P8jqG8C8eSvw6d5rsKFZCfwjwMVJ9ibZBRxk\n9Utd82Rer86e8+vAI1X17mk3MqwkL3nuT3P3Po5/LzAXP3Cuqp+uqouq6h+y+u/+E1X1L6fd16CS\nnNP7ZEiSFwD/HPjz6XY1uN7fAns8yat7h64CHpliS6frOrZYzoHRv2k7FlX1bJIbgMOsvgndUVXH\nptzWwJIcAjrAi5P8JXDLcz8EmgdJ3gj8MPBwbx28gJ+uqo9Mt7OBfRtwV++3FHYAv1NVfzjlnlrx\nMuBDvT+LshN4f1UdnnJPw7oReH9vWeTzwLum3M9QkpzD6g9sf3zL2ln4tUxJ0vablSUdSdI2M/Al\nqREGviQ1wsCXpEYY+JLUCANfkhph4EtSIwx8SWrE/wf7PkEAQHmpsgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f5be23c6c50>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_label0 = np.random.normal(5, 1, 10)\n",
    "x_label1 = np.random.normal(2, 1, 10)\n",
    "xs = np.append(x_label0, x_label1)\n",
    "labels = [0.] * len(x_label0) + [1.] * len(x_label1)\n",
    "\n",
    "plt.scatter(xs, labels)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Define the hyper-parameters, placeholders, and variables:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "learning_rate = 0.001\n",
    "training_epochs = 1000\n",
    "\n",
    "X = tf.placeholder(\"float\")\n",
    "Y = tf.placeholder(\"float\")\n",
    "\n",
    "w = tf.Variable([0., 0.], name=\"parameters\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Define the model:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "def model(X, w):\n",
    "    return tf.add(tf.multiply(w[1], tf.pow(X, 1)),\n",
    "                  tf.multiply(w[0], tf.pow(X, 0)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Given a model, define the cost function:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "y_model = model(X, w)\n",
    "cost = tf.reduce_sum(tf.square(Y-y_model))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Set up the training op, and also introduce a couple ops to calculate some metrics, such as accuracy:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)\n",
    "correct_prediction = tf.equal(Y, tf.to_float(tf.greater(y_model, 0.5)))\n",
    "accuracy = tf.reduce_mean(tf.to_float(correct_prediction))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Prepare the session:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "sess = tf.Session()\n",
    "init = tf.global_variables_initializer()\n",
    "sess.run(init)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Run the training op multiple times on the input data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 8.63226\n",
      "100 3.23953\n",
      "200 2.14632\n",
      "300 1.90881\n",
      "400 1.8572\n",
      "500 1.84599\n",
      "600 1.84356\n",
      "700 1.84303\n",
      "800 1.84291\n",
      "900 1.84289\n"
     ]
    }
   ],
   "source": [
    "for epoch in range(training_epochs):\n",
    "    sess.run(train_op, feed_dict={X: xs, Y: labels})\n",
    "    current_cost = sess.run(cost, feed_dict={X: xs, Y: labels})\n",
    "    if epoch % 100 == 0:\n",
    "        print(epoch, current_cost)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Show some final metrics/results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "learned parameters [ 1.28786051 -0.25033307]\n",
      "accuracy 0.95\n"
     ]
    }
   ],
   "source": [
    "w_val = sess.run(w)\n",
    "print('learned parameters', w_val)\n",
    "\n",
    "print('accuracy', sess.run(accuracy, feed_dict={X: xs, Y: labels}))\n",
    "\n",
    "sess.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Plot the learned function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAEACAYAAABbMHZzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHZRJREFUeJzt3XmcVXX9x/HXB2ZGhmWGRUATBHLPXFhEwG1MTSSXREVQ\nfmFa9uuXaVkmagY9/KXmUqloahhujWhqGqiIiONWyCLiAgguw6LAjGm/tHwU6uf3x/dKI81y79w7\n8733nvfz8ZiHdzn3nPfMQz733M/9nHPM3RERkWTpEDuAiIi0PxV/EZEEUvEXEUkgFX8RkQRS8RcR\nSSAVfxGRBMpJ8TezW8xsk5m92MTzh5jZX83s+dTPj3OxXRERaZ2SHK1nBnAdcHszyzzl7sfmaHsi\nIpKFnOz5u/szwHstLGa52JaIiGSvPXv+I8xsqZk9ZGZfaMftiojIVnLV9mnJEmCAu//DzI4CHgB2\nbadti4jIVtql+Lv7Bw1uP2JmN5hZT3d/d+tlzUwnGxIRyZC7Z9Raz2Xbx2iir29mfRvcHg5YY4X/\nU+5ekD9TpkyJnkH54+dQ/sL8KeT8rZGTPX8zqwaqgF5mthaYApSFOu43Ayea2beBzcCHwMm52K6I\niLROToq/u5/SwvPXA9fnYlsiIpI9HeGbQ1VVVbEjZEX541L+uAo9f6astf2itmJmnm+ZRETymZnh\nEb/wFRGRAqHiLyKSQCr+IiIJpOIvIpJAKv4iIgmk4i8ikkAq/iIiCaTiLyKSQCr+ObR+fewEIiLp\nUfHPkY0bYcgQuPlm0AHKIpLvdHqHHFq1CsaOheHD4frrobw8diIRSQKd3iGyXXeFBQvgww/hgAPg\njTdiJxIRaZyKf4517QrV1XDaaTByJDz8cOxEIiL/SW2fNvTss3DyyXDGGfCTn0DHjrETiUgxak3b\nR8W/jW3cCOPHh/7/nXdCr16xE4lIsVHPPw9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fbddQGWgs\nf2vqZt4V/62cDjwSO0QadgDWNbi/ngIqng2Z2UBgX+C5uEky8kvgPMLxJ4VmEPCOmc1Ita1uNrPy\n2KHS5e5vA1cDa4G3gL+6+7y4qVqlj7tvgrAzBPSJnCcbadXNKMXfzB5L9Qc//Xkp9d9jGixzEbDZ\n3atjZEwiM+sK3Auck/oEkPfM7CvAptQnF6PlU43kmxJgCHC9uw8B/kFoQRQEM+tO2GseAHwO6Gpm\np8RNlROFuCORUd3M5Zx/2tz9iOaeN7PTCB/jv9QugbL3FrBjg/v9Uo8VjNRH9nuBO9z9wdh5MnAA\ncKyZjQHKgW5mdru7fy1yrnStB9a5++LU/XuBQhoYOBx4w93fBTCz+4FRQKHttG0ys77uvsnMtgPq\nYgfKVKZ1M+/aPmY2mvAR/lh3/2fsPGlaBOxsZgNSkw7jgUKbOvktsNzdr4kdJBPufqG77+junyf8\n3ecXUOEn1WpYZ2a7ph46jML64notMMLMOpmZEfIXwhfWW39K/CNwWur2JCDfd4A+k781dTPv5vzN\nbDVQBvwl9dACd/+fiJHSkvrjX0N4Q73F3S+PHCltZnYA8BThFN2e+rnQ3edEDZYhMzuEcJqRY2Nn\nyYSZ7UP4sroUeAP4urv/X9xU6UudsmU8sBlYCnwjNfiQl8ysGqgCegGbgCnAA8Dvgf7AGmCcu/81\nVsbmNJH/QjKsm3lX/EVEpO3lXdtHRETanoq/iEgCqfiLiCSQir+ISAKp+IuIJJCKv4hIAqn4i4gk\nkIq/iEgC/T8q+K/9gov3jwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x7f5be252a9b0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "all_xs = np.linspace(0, 10, 100)\n",
    "plt.plot(all_xs, all_xs*w_val[1] + w_val[0])\n",
    "plt.scatter(xs, labels)\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
